import { createRouter, createWebHashHistory } from 'vue-router';
import AiHome from '../views/AiHome.vue';
import userInfo from '../views/userInfo/index.vue';
import BaseLayout from '../views/BaseLayout.vue';
import LoginLog from '../views/loginLog.vue';
import notUid from '../views/notUid.vue';
import uid from '../views/uid.vue';
import third from '../views/third.vue';

const routes = [
  {
    path: '/',
    name: 'baseLayout',
    component: BaseLayout,
    redirect: '/home/1',
    children: [
      {
        path: 'home/:id',
        name: 'AiHome',
        component: AiHome,
        meta: {
          title: '首页',
          keepAlive: true
        }
      },
      {
        path: 'userInfo/:id',
        name: 'userInfo',
        component: userInfo,
        meta: {
          title: '菜单一',
          keepAlive: true
        }
      },
      {
        path: 'loginLog/:id',
        name: 'loginLog',
        component: LoginLog,
        meta: {
          title: '菜单二',
          keepAlive: true
        }
      },
      {
        path: 'notUid/:id',
        name: 'notUid',
        component: notUid,
        meta: {
          title: '菜单三',
          keepAlive: true
        }
      },
      {
        path: 'uid/:id',
        name: 'uid',
        component: uid,
        meta: {
          title: '菜单四',
          keepAlive: true
        }
      },
      {
        path: 'third/:id',
        name: 'third',
        component: third,
        meta: {
          title: '菜单五',
          keepAlive: true
        }
      }
    ]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

// 设置页面标题
router.beforeEach((to, from, next) => {
  document.title = to.meta.title || 'X平台';
  next();
});

export default router; 